#!/usr/bin/perl
#
open fp,'<',$ARGV[0];

%opcode = (
        "00000","HALT",
        "00001","NOP",
        "01000","ADDI",
        "01001","SUBI",
        "01010","XORI",
        "01011","ANDNI",
        "10100","ROLI",
        "10101","SLLI",
        "10110","RORI",
        "10111","SRLI",
        "10000","ST",
        "10001","LD",
        "10011","STU",
        "11001","BTR",
        "11011","ADD/SUB/XOR/ANDN",
        "11010","ROL/SLL/ROR/SRL/SEQ",
        "11100","SEQ",
        "11101","SLT",
        "11110","SLE",
        "11111","SCO",
        "01100","BEQZ",
        "01101","BNEZ",
        "01110","BLTZ",
        "01111","BGEZ",
        "11000","LBI",
        "10010","SLBI",
        "00100","J",
        "00101","JR",
        "00110","JAL",
        "00111","JALR",
        "00010","SIIC",
        "00011","NOP/RTI",
        );
while ($line = <fp>)    {
    chomp($line);
    if ($line =~ /^# opcode/)   {
        @words = split(" ",$line);
        print $line,"\t",$opcode{$words[2]},"\n";
    }
    else
    {
        print $line,"\n";
    }
}
